<?php
Util::tsRegisterAssetJs('form.js');
/** @var AlimentosController $this */
/** @var Alimentos $model */
/** @var AweActiveForm $form */
$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
    'type' => 'horizontal',
    'id' => 'alimentos-form',
    'enableAjaxValidation' => false,
    'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false,),
    'enableClientValidation' => true,
        ));
?>

<div class="row-fluid">
    <div class="span10">
        <?php
        $this->beginWidget('zii.widgets.CPortlet', array(
            'title' => ($model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Update')) . ' ' . Alimentos::label(1),
        ));
        ?>
        <p class="note">
            <?php echo Yii::t('AweCrud.app', 'Fields with') ?>
            <span class="required">*</span>
            <?php echo Yii::t('AweCrud.app', 'are required') ?> 
        </p>
        <div class="row-fluid">
            <div class="span10">
                <?php
                echo $form->dropDownListRow($model, 'categoria_id', array('' => ' -- Seleccione -- ') + CHtml::listData(Categoria::model()->findAll(), 'id', Categoria::representingColumn()), array(
                    'ajax' => array(
                        'type' => 'POST',
                        'url' => CController::createUrl('/nutricion/alimentos/cargarSubcategorias'),
                        'update' => "#Alimentos_subcategoria_id",
                    ),
                ))
                ?>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span10">
                <?php echo $form->dropDownListRow($model, 'subcategoria_id', array('' => ' -- Seleccione -- ') + CHtml::listData($model->categoria ? $model->categoria->subcategorias : array(), 'id', Subcategoria::representingColumn())) ?>           
            </div>
        </div>
        <div class="row-fluid">
            <div class="span5">
                <?php echo $form->textFieldRow($model, 'nombre', array('maxlength' => 45)) ?>
            </div>
            <div class="span5">
                <?php echo $form->textFieldRow($model, 'descripcion', array('maxlength' => 45)) ?>
            </div>

        </div>
    

        <div class="form-actions">
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'buttonType' => 'submit',
                'type' => 'primary',
                'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
            ));
            ?>
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                //'buttonType'=>'submit',
                'label' => Yii::t('AweCrud.app', 'Cancel'),
                'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')
            ));
            ?>
        </div>

        <?php $this->endWidget(); ?>
    </div>
    <?php $this->endWidget(); ?>
    <div class="span2">
        <?php
        $this->beginWidget('zii.widgets.CPortlet', array(
            'title' => Yii::t('AweCrud.app', 'Operaciones'),
        ));
        $this->widget('zii.widgets.CMenu', array(
            'items' => $this->menu,
            'htmlOptions' => array('class' => 'operations'),
        ));
        ?>
        <?php $this->endWidget(); ?>
    </div>
</div>